package com.CNMedical.web.controller.system;

import java.util.List;

import com.CNMedical.system.domain.DTO.AppletForumCommentDTO;
import com.CNMedical.system.domain.vo.AppletForumCommentVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.CNMedical.common.annotation.Log;
import com.CNMedical.common.core.controller.BaseController;
import com.CNMedical.common.core.domain.AjaxResult;
import com.CNMedical.common.enums.BusinessType;
import com.CNMedical.system.domain.entity.AppletForumComment;
import com.CNMedical.system.service.IAppletForumCommentService;
import com.CNMedical.common.core.page.TableDataInfo;

/**
 * 论坛帖子留言Controller
 * 
 * @author tang
 * @date 2023-03-29
 */
@RestController
@RequestMapping("/system/forumComment")
public class AppletForumCommentController extends BaseController
{
    @Autowired
    private IAppletForumCommentService appletForumCommentService;

    /**
     * 查询论坛帖子留言列表
     */
    @PreAuthorize("@ss.hasPermi('system:forumComment:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletForumCommentDTO appletForumComment)
    {
        startPage();
        List<AppletForumCommentVO> list = appletForumCommentService.selectAppletForumCommentList(appletForumComment);
        return getDataTable(list);
    }

    /**
     * 获取论坛帖子留言详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:forumComment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletForumCommentService.selectAppletForumCommentById(id));
    }

    /**
     * 新增论坛帖子留言
     */
    @PreAuthorize("@ss.hasPermi('system:forumComment:add')")
    @Log(title = "论坛帖子留言", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletForumComment appletForumComment)
    {
        return toAjax(appletForumCommentService.insertAppletForumComment(appletForumComment));
    }

    /**
     * 修改论坛帖子留言
     */
    @PreAuthorize("@ss.hasPermi('system:forumComment:edit')")
    @Log(title = "论坛帖子留言", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletForumComment appletForumComment)
    {
        return toAjax(appletForumCommentService.updateAppletForumComment(appletForumComment));
    }

    /**
     * 删除论坛帖子留言
     */
    @PreAuthorize("@ss.hasPermi('system:forumComment:remove')")
    @Log(title = "论坛帖子留言", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletForumCommentService.deleteAppletForumCommentByIds(ids));
    }
}
